# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

Scheme = 'CriticalMaps'
Scheme_UnitTests = 'CriticalMapsTests'
Scheme_UITests = 'CriticalMapsUITests'
Scheme_SnapshotTests = 'CriticalMapsSnapshotTests'

Screenshots_Output = 'build/screenshots' 

AppIdentifier = 'de.pokuslabs.criticalmassberlin'

skip_docs

default_platform(:ios)

platform :ios do

  desc 'Run unit tests'
  lane :test do

    # Workaround to Resolve SPM Package Dependencies
    # found here: https://github.com/fastlane/fastlane/issues/15454#issuecomment-543761561
    # should be removed again, when Fastlane has fixed this
    sh "cd .. && xcodebuild -resolvePackageDependencies"

    run_tests(
      device: 'iPhone 8',
      scheme: Scheme_UnitTests
    )
  end

  desc 'Run snapshot tests'
  lane :snapshot_test do
    sh "cd .. && xcodebuild -resolvePackageDependencies"
    
    run_tests(
      scheme: Scheme_SnapshotTests,
      device: "iPhone 8"
    )
  end

  desc 'Run UITests'
  lane :ui_test do
    sh "cd .. && xcodebuild -resolvePackageDependencies"

    run_tests(
      device: 'iPhone 8',
      scheme: Scheme_UITests
    )
  end
  
  desc 'Make screenshots with all languages and different devices'
  lane :screenshots_complete do
    capture_ios_screenshots(
      app_identifier: AppIdentifier,
      configuration: 'Debug',
      output_directory: Screenshots_Output,
      scheme: Scheme_UITests
    )
  end

  desc 'Make screenshots in English and iPhone 8'
  lane :screenshots_limited do
    capture_ios_screenshots(
      app_identifier: AppIdentifier,
      configuration: 'Debug',
      output_directory: Screenshots_Output,
      scheme: Scheme_UITests,
      languages: [ "en-US" ],
      devices: [ "iPhone 8" ]
    )
  end
end
